package com.Polymorphic;
//多态
public class AnimalDemo {
    public static void main(String[] args) {
        AnimalOperator ao = new AnimalOperator();

        //这两部分代码等价

        Animal a = new Cat();//向上转型
        Animal b = new Dog();//向上转型
        ao.useAnimal(a);
        ao.useAnimal(b);

           /*Cat c = new Cat();
        Dog d = new Dog();*/
        Cat c = (Cat)a;//向下转型
        Dog d = (Dog)b;//向下转型
        c.eat();
        d.eat();
    }
}
